import { commonParams } from './config.js'

//获取热门搜索词
export function getHotKey(callback){
  const data = Object.assign({},commonParams,{
    platform: 'h5',
    needNewCode: 1
  });
  wx.request({
    url: 'https://luoyan.haletone.club/api/gethotkey',
    data: data,
    header: {
      'Content-Type': 'application/json'
    },
    success(res){
      if (res.statusCode == 200) {
        callback(res.data)
      } else { }
    }
  })
}
//根据搜索词 获取 搜索结果
export function search(query,page,zhida,perpage,callback){
  const data = Object.assign({},commonParams,{
    w: query,
    p: page,
    catZhida: zhida ? 1 : 0,
    zhidaqu: 1,
    t: 0,
    flag: 1,
    ie: 'utf-8',
    sem: 1,
    aggr: 0,
    perpage,	//每页显示条数
    n: perpage,
    remoteplace: 'txt.mqq.all',
    uid: 0,
    needNewCode: 1,
    platform: 'h5',
    format: 'json'
  });
  wx.request({
    url: 'https://luoyan.haletone.club/api/search',
    data: data,
    header:{
      'Content-Type': 'application/json'
    },
    success(res){
      if(res.statusCode == 200){
        callback(res.data)
      }else{}
    }
  })
}

